package com.zzh.api.member.service.impl;


import com.zzh.api.base.response.BaseResponse;
import com.zzh.api.base.service.BaseApiService;
import com.zzh.api.member.entity.MemberEntity;
import com.zzh.api.member.service.IMemberService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zihong.zheng
 * @version 1.0
 * @date 2019/2/7
 * @time 17:40
 * @description
 */
@RestController
public class MemberServiceImpl extends BaseApiService implements IMemberService {

    @Value("${server.port}")
    private String serverPort;

    @Override
    @RequestMapping("/getMember")
    public MemberEntity getMember(@RequestParam("name") String name) {
        MemberEntity memberEntity = new MemberEntity();
        memberEntity.setName(name + ":" +  serverPort);
        memberEntity.setAge(28);
        return memberEntity;
    }

    @Override
    @RequestMapping("/orderToMemberInfo")
    public BaseResponse orderToMemberInfo() {
        try {
            //会员接口消耗1.5秒的时间进行业务处理
            Thread.sleep(1500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return returnSuccess("订单服务接口调用会员服务接口:orderToMemberInfo");

    }

    @Override
    @RequestMapping("/getUserInfo")
    public BaseResponse getUserInfo() {
        System.out.println("会员信息接口开始调用");
        try {
            //会员接口消耗1.5秒的时间进行业务处理
            Thread.sleep(1500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("业务处理完成");
        return returnSuccess("订单服务接口调用会员服务接口:getUserInfo 成功...");
    }

}
